Skip to content

fix buffer capacity#618

Merged
AlexInLog merged 2 commits into
v2from
fix_buffer_capacity
Aug 19, 2024
Merged

fix buffer capacity#618
AlexInLog merged 2 commits into
v2from
fix_buffer_capacity

Conversation

@AlexInLog

@AlexInLog AlexInLog commented Aug 19, 2024

Copy link
Copy Markdown
Owner

#617

Summary by CodeRabbit

  • New Features

    • Improved performance for the buffer operation by maintaining the capacity of the buffer after clearing.
  • Tests

    • Added a new test case to validate the behavior of the buffer when accepting items by moving them, ensuring correct item processing without unnecessary copies.

@coderabbitai

coderabbitai Bot commented Aug 19, 2024

Copy link
Copy Markdown
Contributor
Walkthrough

Walkthrough

The recent changes enhance the rpp::operators::details namespace by improving how the m_bucket container manages memory during its lifecycle. A new capacity variable ensures that m_bucket retains its size after being cleared, optimizing performance and reducing unnecessary allocations. Additionally, a new test case has been added to validate the buffer's behavior when moving items, ensuring the integrity of operations without unnecessary copies.

Changes

Files Change Summary
src/rpp/rpp/operators/buffer.hpp Modified m_bucket logic to store and maintain capacity after clearing, improving efficiency.
src/tests/rpp/test_buffer.cpp Added test case for buffer operations to validate item movement, ensuring correct processing.

Poem

🐰 In the land of code where bunnies play,
Buffers were tweaked in a marvelous way.
With capacity kept, no need to fret,
Moving and grooving, the best is yet!
So hop with delight, let changes unfold,
A tale of improvements in every line told! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b8b0ed5 and a67ac3e.

Files selected for processing (2)
  • src/rpp/rpp/operators/buffer.hpp (1 hunks)
  • src/tests/rpp/test_buffer.cpp (1 hunks)
Additional comments not posted (2)
src/rpp/rpp/operators/buffer.hpp (1)

44-48: Performance optimization approved.

Storing and reusing the capacity of m_bucket minimizes reallocations, improving performance when refilling the bucket.

src/tests/rpp/test_buffer.cpp (1)

107-118: Test case addition approved.

The "accept by moving" test case effectively verifies that the buffer handles item movement correctly, ensuring operations proceed without unnecessary copies.

@github-actions

Copy link
Copy Markdown
Contributor

BENCHMARK RESULTS (AUTOGENERATED)

ci-ubuntu-gcc

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 301.00 ns 2.16 ns 2.16 ns 1.00
Subscribe empty callbacks to empty observable via pipe operator 312.92 ns 2.16 ns 2.22 ns 0.97

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 705.08 ns 0.31 ns 0.31 ns 1.00
from array of 1 - create + subscribe + current_thread 1044.51 ns 3.43 ns 3.42 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 2266.41 ns 118.81 ns 113.79 ns 1.04
defer from array of 1 - defer + create + subscribe + immediate 733.83 ns 0.31 ns 0.31 ns 1.00
interval - interval + take(3) + subscribe + immediate 2135.48 ns 59.23 ns 59.23 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3057.77 ns 32.44 ns 32.48 ns 1.00
from array of 1 - create + as_blocking + subscribe + new_thread 30601.35 ns 28466.86 ns 27891.32 ns 1.02
from array of 1000 - create + as_blocking + subscribe + new_thread 44023.39 ns 49586.95 ns 51211.95 ns 0.97
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 3507.48 ns 143.20 ns 139.37 ns 1.03

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1099.64 ns 0.31 ns 0.31 ns 1.00
immediate_just+filter(true)+subscribe 848.43 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 995.71 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 879.94 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+first()+subscribe 1236.85 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+last()+subscribe 915.85 ns 0.31 ns 0.31 ns 1.00
immediate_just+take_last(1)+subscribe 1114.31 ns 18.21 ns 17.97 ns 1.01
immediate_just(1,2,3)+element_at(1)+subscribe 833.24 ns 0.31 ns 0.31 ns 1.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 262.44 ns 2.16 ns 2.16 ns 1.00
current_thread scheduler create worker + schedule 365.05 ns 5.87 ns 5.55 ns 1.06
current_thread scheduler create worker + schedule + recursive schedule 821.92 ns 55.85 ns 56.69 ns 0.99

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 860.97 ns 0.31 ns 0.31 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 896.74 ns 0.31 ns 0.31 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 2360.67 ns 156.24 ns 158.66 ns 0.98
immediate_just+buffer(2)+subscribe 1548.39 ns 13.89 ns 13.58 ns 1.02
immediate_just+window(2)+subscribe + subscsribe inner 2391.26 ns 1064.23 ns 1108.91 ns 0.96

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 859.93 ns - - 0.00
immediate_just+take_while(true)+subscribe 856.75 ns 0.31 ns 0.31 ns 1.00

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 2083.12 ns 0.31 ns 0.31 ns 1.00

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 3406.89 ns 171.64 ns 180.37 ns 0.95
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3611.47 ns 165.46 ns 185.41 ns 0.89
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 133.46 ns 126.22 ns 1.06
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3643.35 ns 990.71 ns 879.62 ns 1.13
immediate_just(1) + zip(immediate_just(2)) + subscribe 2162.08 ns 214.46 ns 203.05 ns 1.06

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 34.55 ns 14.59 ns 14.72 ns 0.99
subscribe 100 observers to publish_subject 199976.80 ns 16452.61 ns 15165.59 ns 1.08
100 on_next to 100 observers to publish_subject 27115.80 ns 20292.08 ns 17213.60 ns 1.18

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1325.38 ns 12.66 ns 12.66 ns 1.00
basic sample with immediate scheduler 1366.84 ns 5.24 ns 5.55 ns 0.94

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 937.86 ns 0.31 ns 0.31 ns 1.00

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2123.92 ns 977.44 ns 971.58 ns 1.01

ci-macos

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 1201.70 ns 4.81 ns 4.84 ns 0.99
Subscribe empty callbacks to empty observable via pipe operator 1210.61 ns 4.82 ns 5.03 ns 0.96

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 2965.63 ns 0.35 ns 0.29 ns 1.18
from array of 1 - create + subscribe + current_thread 2992.81 ns 40.13 ns 41.74 ns 0.96
concat_as_source of just(1 immediate) create + subscribe 8264.61 ns 454.24 ns 408.45 ns 1.11
defer from array of 1 - defer + create + subscribe + immediate 2822.92 ns 0.42 ns 0.29 ns 1.46
interval - interval + take(3) + subscribe + immediate 7576.42 ns 163.40 ns 139.01 ns 1.18
interval - interval + take(3) + subscribe + current_thread 9737.44 ns 131.83 ns 117.05 ns 1.13
from array of 1 - create + as_blocking + subscribe + new_thread 112523.10 ns 109770.14 ns 80677.79 ns 1.36
from array of 1000 - create + as_blocking + subscribe + new_thread 132869.80 ns 122207.30 ns 98893.67 ns 1.24
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 13141.90 ns 569.18 ns 459.64 ns 1.24

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 3597.37 ns 0.32 ns 0.27 ns 1.19
immediate_just+filter(true)+subscribe 2619.10 ns 0.29 ns 0.26 ns 1.10
immediate_just(1,2)+skip(1)+subscribe 3417.40 ns 0.29 ns 0.26 ns 1.13
immediate_just(1,1,2)+distinct_until_changed()+subscribe 2539.07 ns 0.58 ns 0.51 ns 1.12
immediate_just(1,2)+first()+subscribe 4462.03 ns 0.32 ns 0.25 ns 1.27
immediate_just(1,2)+last()+subscribe 2978.42 ns 0.30 ns 0.25 ns 1.20
immediate_just+take_last(1)+subscribe 4035.09 ns 0.32 ns 87.40 ns 0.00
immediate_just(1,2,3)+element_at(1)+subscribe 2719.17 ns 0.28 ns 0.25 ns 1.12

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 1390.36 ns 5.39 ns 5.13 ns 1.05
current_thread scheduler create worker + schedule 1485.38 ns 47.14 ns 48.96 ns 0.96
current_thread scheduler create worker + schedule + recursive schedule 2491.87 ns 255.21 ns 267.69 ns 0.95

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 2609.53 ns 5.18 ns 4.20 ns 1.23
immediate_just+scan(10, std::plus)+subscribe 2910.09 ns 0.61 ns 0.47 ns 1.31
immediate_just+flat_map(immediate_just(v*2))+subscribe 6655.75 ns 498.24 ns 413.12 ns 1.21
immediate_just+buffer(2)+subscribe 3234.01 ns 87.24 ns 74.45 ns 1.17
immediate_just+window(2)+subscribe + subscsribe inner 7633.68 ns 2978.91 ns 2666.97 ns 1.12

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 2586.10 ns - - 0.00
immediate_just+take_while(true)+subscribe 2604.94 ns 0.29 ns 0.23 ns 1.24

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 6174.86 ns 6.45 ns 5.13 ns 1.26

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 9608.72 ns 556.92 ns 543.03 ns 1.03
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 11253.67 ns 547.22 ns 539.30 ns 1.01
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 609.59 ns 520.09 ns 1.17
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 10028.57 ns 2363.01 ns 2109.66 ns 1.12
immediate_just(1) + zip(immediate_just(2)) + subscribe 6404.25 ns 1034.89 ns 960.07 ns 1.08

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 92.84 ns 58.72 ns 54.33 ns 1.08
subscribe 100 observers to publish_subject 481381.00 ns 54817.94 ns 43947.63 ns 1.25
100 on_next to 100 observers to publish_subject 61031.41 ns 25022.84 ns 19887.60 ns 1.26

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 3653.13 ns 87.88 ns 71.69 ns 1.23
basic sample with immediate scheduler 12396.00 ns 28.01 ns 20.36 ns 1.38

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 2851.78 ns 0.35 ns 0.26 ns 1.36

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 8409.70 ns 4978.43 ns 4857.49 ns 1.02

ci-ubuntu-clang

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 265.43 ns 1.57 ns 0.88 ns 1.79
Subscribe empty callbacks to empty observable via pipe operator 265.98 ns 1.56 ns 0.88 ns 1.78

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 585.82 ns 0.31 ns 0.31 ns 1.00
from array of 1 - create + subscribe + current_thread 795.69 ns 4.02 ns 4.02 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 2404.99 ns 134.65 ns 137.81 ns 0.98
defer from array of 1 - defer + create + subscribe + immediate 776.11 ns 0.31 ns 0.31 ns 1.00
interval - interval + take(3) + subscribe + immediate 2207.13 ns 58.31 ns 58.26 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3231.13 ns 30.88 ns 30.86 ns 1.00
from array of 1 - create + as_blocking + subscribe + new_thread 27168.84 ns 28572.82 ns 30022.97 ns 0.95
from array of 1000 - create + as_blocking + subscribe + new_thread 38781.36 ns 35581.44 ns 36635.71 ns 0.97
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 3651.10 ns 156.97 ns 158.43 ns 0.99

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1176.64 ns 0.31 ns 0.31 ns 1.00
immediate_just+filter(true)+subscribe 850.58 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 1072.50 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 869.00 ns 0.62 ns 0.62 ns 1.00
immediate_just(1,2)+first()+subscribe 1366.91 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+last()+subscribe 998.83 ns 0.31 ns 0.31 ns 1.00
immediate_just+take_last(1)+subscribe 1200.19 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2,3)+element_at(1)+subscribe 853.21 ns 0.31 ns 0.31 ns 1.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 278.31 ns 1.56 ns 0.88 ns 1.78
current_thread scheduler create worker + schedule 390.92 ns 4.02 ns 4.01 ns 1.00
current_thread scheduler create worker + schedule + recursive schedule 844.84 ns 59.19 ns 55.89 ns 1.06

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 846.17 ns 0.31 ns 0.31 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 970.78 ns 0.31 ns 0.31 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 2257.01 ns 136.78 ns 150.55 ns 0.91
immediate_just+buffer(2)+subscribe 1511.21 ns 13.89 ns 13.59 ns 1.02
immediate_just+window(2)+subscribe + subscsribe inner 2478.81 ns 933.94 ns 929.75 ns 1.00

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 835.17 ns - - 0.00
immediate_just+take_while(true)+subscribe 836.23 ns 0.31 ns 0.31 ns 1.00

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 1976.54 ns 0.31 ns 0.31 ns 1.00

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 3275.84 ns 158.55 ns 163.01 ns 0.97
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3692.59 ns 146.71 ns 147.84 ns 0.99
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 143.84 ns 144.77 ns 0.99
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3333.37 ns 843.59 ns 840.59 ns 1.00
immediate_just(1) + zip(immediate_just(2)) + subscribe 2241.34 ns 201.39 ns 202.90 ns 0.99

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 53.88 ns 17.82 ns 17.69 ns 1.01
subscribe 100 observers to publish_subject 211232.60 ns 16021.48 ns 16080.57 ns 1.00
100 on_next to 100 observers to publish_subject 35239.56 ns 17713.92 ns 20492.00 ns 0.86

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1298.96 ns 11.12 ns 11.11 ns 1.00
basic sample with immediate scheduler 1300.64 ns 5.86 ns 5.86 ns 1.00

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 996.11 ns 0.31 ns 0.31 ns 1.00

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2194.50 ns 1230.85 ns 1225.19 ns 1.00

ci-windows

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 566.87 ns 4.01 ns 4.01 ns 1.00
Subscribe empty callbacks to empty observable via pipe operator 582.14 ns 4.01 ns 4.01 ns 1.00

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 1178.71 ns 5.55 ns 5.55 ns 1.00
from array of 1 - create + subscribe + current_thread 1470.37 ns 15.74 ns 15.74 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 3766.14 ns 172.32 ns 174.79 ns 0.99
defer from array of 1 - defer + create + subscribe + immediate 1194.84 ns 5.24 ns 5.24 ns 1.00
interval - interval + take(3) + subscribe + immediate 3412.64 ns 133.44 ns 133.54 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3499.10 ns 54.21 ns 52.83 ns 1.03
from array of 1 - create + as_blocking + subscribe + new_thread 124475.00 ns 123225.00 ns 115388.89 ns 1.07
from array of 1000 - create + as_blocking + subscribe + new_thread 136425.00 ns 133477.78 ns 131550.00 ns 1.01
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 5662.87 ns 210.04 ns 205.80 ns 1.02

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 2113.18 ns 12.86 ns 12.87 ns 1.00
immediate_just+filter(true)+subscribe 1330.88 ns 11.75 ns 11.73 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 1735.45 ns 13.05 ns 13.87 ns 0.94
immediate_just(1,1,2)+distinct_until_changed()+subscribe 1644.34 ns 15.81 ns 15.81 ns 1.00
immediate_just(1,2)+first()+subscribe 2104.91 ns 12.64 ns 12.64 ns 1.00
immediate_just(1,2)+last()+subscribe 1837.10 ns 14.08 ns 14.08 ns 1.00
immediate_just+take_last(1)+subscribe 2266.99 ns 59.02 ns 60.02 ns 0.98
immediate_just(1,2,3)+element_at(1)+subscribe 1327.15 ns 13.77 ns 13.78 ns 1.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 476.92 ns 6.63 ns 6.17 ns 1.07
current_thread scheduler create worker + schedule 664.81 ns 13.71 ns 13.70 ns 1.00
current_thread scheduler create worker + schedule + recursive schedule 1353.51 ns 107.87 ns 105.12 ns 1.03

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 1299.62 ns 11.10 ns 11.27 ns 0.98
immediate_just+scan(10, std::plus)+subscribe 1433.50 ns 21.27 ns 21.29 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 3466.88 ns 207.40 ns 201.26 ns 1.03
immediate_just+buffer(2)+subscribe 2603.33 ns 58.38 ns 59.79 ns 0.98
immediate_just+window(2)+subscribe + subscsribe inner 3950.00 ns 1302.49 ns 1300.64 ns 1.00

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 1611.44 ns 11.45 ns 11.46 ns 1.00
immediate_just+take_while(true)+subscribe 1308.09 ns 11.76 ns 11.74 ns 1.00

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 3207.84 ns 7.71 ns 7.71 ns 1.00

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 5262.22 ns 219.93 ns 224.12 ns 0.98
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 5456.94 ns 211.98 ns 210.07 ns 1.01
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 196.45 ns 199.28 ns 0.99
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 5397.87 ns 942.88 ns 949.16 ns 0.99
immediate_just(1) + zip(immediate_just(2)) + subscribe 3610.34 ns 538.11 ns 512.45 ns 1.05

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 36.50 ns 19.75 ns 20.39 ns 0.97
subscribe 100 observers to publish_subject 266400.00 ns 28283.33 ns 29154.29 ns 0.97
100 on_next to 100 observers to publish_subject 51595.24 ns 32660.61 ns 32711.43 ns 1.00

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1877.69 ns 55.91 ns 56.46 ns 0.99
basic sample with immediate scheduler 1867.39 ns 36.72 ns 36.75 ns 1.00

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 1458.67 ns 19.97 ns 19.98 ns 1.00

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2149.34 ns 341.49 ns 342.23 ns 1.00

@sonarqubecloud

Copy link
Copy Markdown

@AlexInLog AlexInLog merged commit b4146dd into v2 Aug 19, 2024
@AlexInLog AlexInLog deleted the fix_buffer_capacity branch August 19, 2024 14:24
m_observer.on_next(std::move(m_bucket));

m_bucket.clear();
m_bucket.reserve(capacity);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter? I though clear doesn't relinquish memory unless you shrink_to_fit

@AlexInLog AlexInLog Aug 19, 2024

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was expecting the same but in case of moving vector out it actually also moves-out capacity/size
https://godbolt.org/z/1fhhYW1xP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants